#-------------------------------------------------------------------------------
# Name:        模块1
# Purpose:
#
# Author:      sy
#
# Created:
# Copyright:   (c) sy
# Licence:     <your licence>
#-------------------------------------------------------------------------------
# coding: utf-8
#
##1、分别在在相机预览界面和录像预览界面点击前后摄像头切换图标 ,重复次数不低于1000次
##2、在相机预览界面，拍摄一张相片,再点击摄像头切换图标切换到另一摄像头拍摄一张相片，重复次数不低于1000次
##3、在录像预览界面，点击拍摄一段视频，再点击摄像头切换图标切换到另一摄像头拍摄一段视频
##，来回切换拍摄，重复次数不低于1000次。
##import uiautomator2 as u2
##import time
#d = u2.connect()


import sys
import getopt

import wifi_Button as wfb

w = wfb.camera_1

##if len(sys.argv) == 1:
##    w.devices_connect
##else:
##    for i in range(1, len(sys.argv)):
##
##        w.devices_connect(sys.argv[i])



def main(argv):
   cishu = ''
   ssid = ''
   password = ''
   try:
      #opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])

      opts, args = getopt.getopt(argv,"hc:s:p:",["cishu=","ssid=", "password="])
      #“hi:o:m:”  h 表示是一个开关选项，帮助开关；"i:"和"o:" "m:"则表示后面应该带一个参数。

   except getopt.GetoptError:
      print ('test.py -c <cishu> -s <ssid> -p <password>')
      sys.exit(2)
   for opt, arg in opts:
      if opt == '-h':
         print ('test.py -c <cishu> -s <ssid> -p <password>')
         sys.exit()
      elif opt in ("-c", "--cishu"):
         cishu = arg + 1
         return cishu
      elif opt in ("-s", "--ssid"):
         ssid = arg
         return ssid
      elif opt in ("-p", "--password"):
        password = arg
        return password




#test 1.1
def test1_1():
    main(sys.argv[1:])
    w.start_app_1()
    w.network_internet()
    w.wifi_id()
    for i in range(1, cishu):
        print("wifi开关，第{}轮".format(i))
        w.wifi_ON()
        w.wifi_OFF()

if len(sys.argv) == 1:
    test1_1(1001)
    #print("1000")
##elif len(sys.argv) == 2:
##    cishu = int(sys.argv[1])
##    test1_1(cishu + 1)
##    #print(cishu)
else:
    test1_1()




